using UnityEngine;
using System.Collections;

//An object which exists in a character's mind
//Contains the representation of their feelings about the object, and their proximity from it
//Each mental object is an audio sprite
public class MentalObject {
	
	private GameObject obj;//the mental object's "true" gameobject
	public GameObject Obj {
		get {return obj;}
		set {obj = Obj;}
	}
	
	//The mental object's audio sprite
	private AudioSprite aSprite;
	
	//the % proximity from the character
	//0 is out of range, 1 is colliding
	private float prox; 
	public float Prox {
		get {return prox;}
		set {prox = bindPercent(value);}
	}
	
	//how much, from 0 to 1 does the character like this object?
	private float like;
	public float Like {
		get {return like;}
		set {like = bindPercent(value);}
	}
	
	public MentalObject(GameObject _obj, float _prox, float _like) {
		obj = _obj;
		Prox = _prox;
		Like = _like;
		aSprite = obj.GetComponent<AudioSprite>();
	}
	
	//set the mental object's volume to a 0 to 1 percent
	public void setVolume(float volume) {
		aSprite.setChannelVolume(volume);
	}
	
	public bool isPlaying() {
		return aSprite.Playing;
	}
	
	//Return the mental object's note
	public float getNote() {
		return aSprite.Note;
	}
	
	
	
	//bind a percent value to the 0 to 1 range
	private float bindPercent(float val) {
		if (val < 0) return 0;
		else if(val > 1) return 1;
		else return val;
	}
}
